package com.datang.pet.api.commentController;/*
 * @auther 顶风少年
 * @mail dfsn19970313@foxmail.com
 * @date 2019-06-15 19:07
 * @notify
 * @version 1.0
 */

import com.datang.pet.common.response.Result;
import com.datang.pet.common.utils.MD5;
import com.datang.pet.common.utils.StringUtils;
import com.datang.pet.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
public class GetTwoCommentByOneCommentIdNotInIdOrderByDateController {
    @Autowired
    private CommentService commentService;

    @GetMapping("/getTwoCommentByOneCommentIdNotInIdOrderByDate")
    public Result getTwoCommentByOneCommentIdNotInIdOrderByDate(String oneCommentId, String notTwoId, Date time,String userId) throws Exception {

        if (!StringUtils.isNUll(oneCommentId)) {
            throw new Exception("一级评论id为空");
        }
        if (!StringUtils.isNUll(oneCommentId)) {
            throw new Exception("需要排除的评论id为空");
        }
        try {
            userId = (MD5.decryptData(userId));
        } catch (Exception e) {
            throw new Exception("userId解密出错！");
        }
        return Result.ok(commentService.getTwoCommentByOneCommentIdNotInIdOrderByDate(oneCommentId, notTwoId, time,userId));
    }
}
